<template>
	<div>
		<el-dialog
		  title="得分结果"
		  :visible.sync="dialogVisible"
		  width="30%"
		  center
		  :before-close="handleClose">
		  <div class="text-center" v-if="typeTxt=='模拟考试'">
			  <div class="u-font-20 ">本次考试得分 <span class="e-color-d-1"> {{grade}}</span>分</div>
			  <div class="u-font-20 u-margin-top-20 ">考试结果 <span class="e-color-d-1"> {{pass}}</span></div>
		  </div>
		  
		  <div class="text-center" v-if="typeTxt=='精选题库'">

		  			  <div class="u-font-20 ">本次考试答对 <span class="e-color-s-1"> {{realNum}}</span></div>
		  			  <div class="u-font-20 ">本次考试答错 <span class="e-color-d-1">  {{defaultNum}}</span></div>
		  </div>
		  <span slot="footer" class="dialog-footer">
		    <el-button @click="gomis">错题查看</el-button>
		    <el-button type="primary" @click="handleClose">返回题库</el-button>
		  </span>
		</el-dialog>

	</div>
</template>

<script>
	export default{
		name:'gradeDialog',
		props:{
			dialogVisible:{
				type:Boolean,
				default:false
			},
			typeTxt:{
				type:String,
				default:''
			},
			list:{
				type:Array,
				default:()=>[]
			}
		},
		data(){
			return{
				grade:'',
				pass:'',
				realNum:0,
				defaultNum:0
			}
		},
		watch:{
			dialogVisible:{
				immediate:true,
				handler(v){
					if(v){
						this.get()
					}
				}
			}
		},
		created() {

		},
		methods:{
			gomis(){
				this.$router.push('/recode?status=1')
			},
			handleClose(){
				this.$router.replace('/index')
			},
			get(){
				if(this.typeTxt=='精选题库'){
					let ask=this.list;
			
					ask.forEach(item=>{
						if(item.resultInfo){
							if(item.resultInfo.pass){
								this.realNum++
							}else{
								this.defaultNum++
							}
						}
						
					})
				    
			
					// this.pass=res.grade>=res.pass?'合格':'不合格'
				}
				
				if(this.typeTxt=='模拟考试'){
					this.axios('/user/examDetail', {
					}).then(res => {
						this.grade=res.grade;
						this.pass=res.grade>=res.pass?'合格':'不合格'
					}).catch(err => {
					
					})
				}
			
			}
		}
	}
</script>

<style>
</style>
